﻿Imports System.Data.OleDb
Public Class newroute
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        flKml.SaveAs(Request.MapPath("uploads") & "/" & flKml.FileName)

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionStringx").ConnectionString)
        Dim SqlString As String = "INSERT INTO routes (title, description, difficulty, start_location, end_location, cannonical_kml, type, length, duration, created_by) VALUES (@Xtitle, @Xdesc,  @Xdiff, @Xstloc, @Xenloc, @Xkml,  @Xtype,  @Xlen, @Xdur, @Xcreat)"
        'Dim SqlString As String = "INSERT into users (username, [password]) VALUES ('a','b')"     channel, @f9
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@Xtitle", txtTitle.Text)
        cmd.Parameters.AddWithValue("@Xdesc", txtDesc.Text)
        cmd.Parameters.AddWithValue("@Xdiff", drpDiff.Text)
        cmd.Parameters.AddWithValue("@Xstloc", txtStartLoc.Text)
        cmd.Parameters.AddWithValue("@Xenloc", txtEndLoc.Text)
        cmd.Parameters.AddWithValue("@Xkml", "uploads/" & flKml.FileName)
        cmd.Parameters.AddWithValue("@Xtype", drpType.Text)
        cmd.Parameters.AddWithValue("@Xlen", txtLength.Text)
        cmd.Parameters.AddWithValue("@Xdur", txtDuration.Text)

        cmd.Parameters.AddWithValue("@Xcreat", 7)

        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        oleDbConn.Close()
        '   MsgBox("Record Added.", MsgBoxStyle.Information)
        Response.Redirect("route.aspx")
    End Sub
End Class